package com.zho.util;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public abstract class DateHelpers {


	public static String convert2String(java.util.Date date, String format) {
		if (date == null) {
			return "";
		}
		try {
			DateFormat formater = new SimpleDateFormat(format);
			return formater.format(date);
		} catch (Exception e) {
			return "";
		}
	}
	
	public static java.util.Date getCurrentDate() {
		return new java.util.Date();
	}
	
    /**
     * 
     * @param date
     * @param format
     * @return
     * @throws Exception
     */
    public static String dateToString(Date date, String format) throws Exception {
        try {
            if (date == null) {
                return "";
            }
            SimpleDateFormat fm = new SimpleDateFormat(format);
            return fm.format(date);
        } catch (Exception e) {
            throw new Exception("dateToString(...)", e);
        }
    }
	
}
